#ifndef GEOMETRY_H
#define GEOMETRY_H

#include <QtCore/QObject>
#include <QtCore/QDebug>
#include <QPainter>

#include "mapadapter.h"

class Point;

class Geometry : public QObject
{
    friend class LineString;
    Q_OBJECT
public:
    explicit Geometry(QString name = QString());
    virtual ~Geometry();

    QString GeometryType;


    bool Equals(Geometry* geom);

    QString toString();

    QString name() const;

    Geometry* parentGeometry() const;

    bool isVisible() const;

    void setName(QString name);

    QPen* pen() const;

    virtual QRectF boundingBox()=0;
    virtual bool Touches(Point* geom, const MapAdapter* mapadapter)=0;
    virtual void draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset)=0;
    virtual bool hasPoints() const;
    virtual bool hasClickedPoints() const;
    virtual void setPen(QPen* pen);
    virtual QList<Geometry*> clickedPoints();
    virtual QList<Point*> points()=0;

private:
    Geometry* myparentGeometry;
    Geometry(const Geometry& old);
    Geometry& operator=(const Geometry& rhs);

protected:
    QPen* mypen;
    bool visible;
    QString myname;
    void setParentGeometry(Geometry* geom);

signals:
    void updateRequest(Geometry* geom);
    void updateRequest(QRectF rect);
    void geometryClicked(Geometry* geometry, QPoint point);

    void positionChanged(Geometry* geom);

public slots:
    virtual void setVisible(bool visible);
};

#endif
